package com.gyg.controller;

import com.gyg.client.CloudPictureClient;
import com.gyg.returns.RespEntity;
import com.gyg.returns.RespTable;
import com.gyg.vo.param.BanParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@Api(value = "图片模块", tags = "图片模块")
@RequestMapping("/cloud-picture")
public class CloudPictureController {

    @Resource
    private CloudPictureClient cloudPictureClient;

    @GetMapping("/list")
    @ApiOperation(value = "图片列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "page", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "limit", value = "每页数量", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "ban", value = "封禁标识", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "username", value = "用户账号", required = true),
    })
    public RespTable pictureList(@RequestParam(value = "page", required = true) Integer page,
                                 @RequestParam(value = "limit", required = true) Integer limit,
                                 @RequestParam(value = "ban", required = true) Integer ban,
                                 @RequestParam(value = "username", required = false) String username) {
        RespTable respTable = cloudPictureClient.pictureList(page, limit, ban, username);
        return respTable;
    }

    @PutMapping("/ban")
    @ApiOperation(value = "封禁图片")
    public RespEntity banPicture(BanParam banParam) {
        RespEntity respEntity = cloudPictureClient.banPicture(banParam);
        return respEntity;
    }

    @PutMapping("/unseal")
    @ApiOperation(value = "解封图片")
    public RespEntity unsealPicture(BanParam banParam) {
        RespEntity respEntity = cloudPictureClient.unsealPicture(banParam);
        return respEntity;
    }

}
